package com.aurora.oa.mycenter.view;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.aurora.oa.R;
import com.aurora.oa.activity.BaseActivity;
import com.aurora.oa.login.view.ActivityLogin;
import com.aurora.oa.utils.SharedPreferencesUtil;
import com.aurora.oa.utils.ToastUtil;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/5/5 0005.
 */
public class SettingActivity extends BaseActivity {
    @Bind(R.id.tv_message_send_setting)
    TextView tvMessageSendSetting;
    @Bind(R.id.tv_clean_cash)
    TextView tvCleanCash;
    @Bind(R.id.tv_secret_setting)
    TextView tvSecretSetting;
    @Bind(R.id.tv_option_feedback)
    TextView tvOptionFeedback;
    @Bind(R.id.tv_logout)
    TextView tvLogout;
    ProgressDialog dialog;
    Handler handler = new Handler();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initTitlebar(true, "设置", true);
        setMyContentView(R.layout.activity_setting);
    }

    @OnClick({R.id.tv_message_send_setting, R.id.tv_clean_cash, R.id.tv_secret_setting, R.id.tv_option_feedback, R.id.tv_logout})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_message_send_setting:
                startActivity(new Intent(SettingActivity.this,MessageSendSetting.class));
                break;
            case R.id.tv_clean_cash:
                dialog = ProgressDialog.show(this,null,"正在清理缓存...");
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        dialog.dismiss();
                        ToastUtil.show(getApplicationContext(),"清理完成");
                    }
                },5000);
                break;
            case R.id.tv_secret_setting:
                startActivity(new Intent(SettingActivity.this,GestureSecretSettingActivity.class));
                break;
            case R.id.tv_option_feedback:
                startActivity(new Intent(SettingActivity.this,OptionFeedbackActivity.class));
                break;
            case R.id.tv_logout:
                SharedPreferencesUtil.saveString(this,SharedPreferencesUtil.USER_NAME,"");
                SharedPreferencesUtil.saveString(this,SharedPreferencesUtil.PASS_WORD,"");
                Intent intent = new Intent();
                intent.setClass(SettingActivity.this, ActivityLogin.class);     //B为你按退出按钮所在的activity
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  //最关键是这句
                startActivity(intent);
                finish();
                break;
        }
    }
}
